package com.autumn.common.api.constants;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.autumn.common.api.domain.values.IntegerConstantItemValue;

/**
 * 水平对齐方式常量
 * 
 * @author 杨昌国 2018-11-20 09:17:04
 */
public final class HorizontalAlignmentConstant implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3541156766046802189L;

	/**
	 * 居左
	 */
	public static final int LEFT = 1;

	/**
	 * 居中
	 */
	public static final int CENTER = 2;

	/**
	 * 居右
	 */
	public static final int RIGHT = 3;
	

	private static final Map<Integer, IntegerConstantItemValue> NAME_MAP = new HashMap<>();

	static {
		NAME_MAP.put(LEFT, new IntegerConstantItemValue(LEFT, "居左", ""));
		NAME_MAP.put(CENTER, new IntegerConstantItemValue(CENTER, "居中", ""));
		NAME_MAP.put(RIGHT, new IntegerConstantItemValue(RIGHT, "居右", ""));
	}

	/**
	 * 是否存在
	 * 
	 * @param value
	 *            值
	 * @return
	 */
	public static boolean exist(Integer value) {
		if (value == null) {
			return false;
		}
		return NAME_MAP.containsKey(value);
	}

	/**
	 * 获取名称
	 * 
	 * @param value
	 *            值
	 * @return
	 */
	public static String getName(Integer value) {
		IntegerConstantItemValue item = NAME_MAP.get(value);
		if (item == null) {
			return "";
		}
		return item.getName();
	}

	/**
	 * 项目集合
	 * 
	 * @return
	 */
	public static Collection<IntegerConstantItemValue> items() {
		return NAME_MAP.values();
	}
}
